﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xunit;

namespace MvcWiki.Test.Model
{
    public class WikiPageRevisionFacts
    {
        [Fact]
        public void Can_Be_Created()
        {
            new MvcWiki.Model.WikiPageRevision(DateTime.Now, "Content");
        }

        [Fact]
        public void Has_Created_Property()
        {
            var pageRevision = new MvcWiki.Model.WikiPageRevision(DateTime.Now, "Content");

            DateTime created = pageRevision.Created;
        }

        [Fact]
        public void Equals_To_Self()
        {
            var pageRevision1 = new MvcWiki.Model.WikiPageRevision(DateTime.Now, "Content");

            Assert.True(pageRevision1.Equals(pageRevision1));
        }

        [Fact]
        public void Equals_To_Another()
        {
            var now = DateTime.Now;

            var pageRevision1 = new MvcWiki.Model.WikiPageRevision(now, "Content");

            var pageRevision2 = new MvcWiki.Model.WikiPageRevision(now, "Content");

            Assert.True(pageRevision1.Equals(pageRevision2));
        }

        [Fact]
        public void Not_Equals_To_Another()
        {
            var pageRevision1 = new MvcWiki.Model.WikiPageRevision(DateTime.Now, "Content");

            var pageRevision2 = new MvcWiki.Model.WikiPageRevision(DateTime.Now.AddDays(1), "Content");

            Assert.False(pageRevision1.Equals(pageRevision2));
        }
        
        [Fact]
        public void Not_Equals_To_Null()
        {
            var pageRevision = new MvcWiki.Model.WikiPageRevision(DateTime.Now, "Content");

            Assert.False(pageRevision.Equals(null));
        }

        [Fact]
        public void Not_Equals_To_Another_Type()
        {
            var pageRevision = new MvcWiki.Model.WikiPageRevision(DateTime.Now, "Content");

            var obj = new object();

            Assert.False(pageRevision.Equals(obj));
        }

        [Fact]
        public void Eq_To_Self()
        {
            var pageRevision1 = new MvcWiki.Model.WikiPageRevision(DateTime.Now, "Content");

            var pageRevision2 = pageRevision1;

            Assert.True(pageRevision1 == pageRevision2);
        }

        [Fact]
        public void Eq_To_Another()
        {
            var now = DateTime.Now;

            var pageRevision1 = new MvcWiki.Model.WikiPageRevision(now, "Content");

            var pageRevision2 = new MvcWiki.Model.WikiPageRevision(now, "Content");

            Assert.True(pageRevision1 == pageRevision2);
        }

        [Fact]
        public void Not_Eq_To_Another()
        {
            var pageRevision1 = new MvcWiki.Model.WikiPageRevision(DateTime.Now, "Content");

            var pageRevision2 = new MvcWiki.Model.WikiPageRevision(DateTime.Now.AddDays(1), "Content");

            Assert.True(pageRevision1 != pageRevision2);
        }

        [Fact]
        public void Not_Eq_To_Another_Type()
        {
            var pageRevision1 = new MvcWiki.Model.WikiPageRevision(DateTime.Now, "Content");

            var pageRevision2 = new object();

            Assert.True(pageRevision1 != pageRevision2);
        }

        [Fact]
        public void Not_Eq_To_Null()
        {
            var pageRevision1 = new MvcWiki.Model.WikiPageRevision(DateTime.Now, "Content");

            MvcWiki.Model.WikiPageRevision pageRevision2 = null;

            Assert.True(pageRevision1 != pageRevision2);
        }

        [Fact]
        public void Has_Content_Property()
        {
            var pageRevision = new MvcWiki.Model.WikiPageRevision(DateTime.Now, "Content");

            string content = pageRevision.Content;
        }

    }
}
